package app

import (
	"go.uber.org/fx"
	"mallgo/core"
	"mallgo/internal/resources/app/resource"
)

func InitAppRouter(orderResource *resource.AppResource, s *core.AppServer) {
	controller := NewAppController(orderResource)

	// 订单相关路由组
	appMenuGroup := s.Engine.Group("/app")
	{
		appMenuGroup.POST("/create", controller.Create)
		appMenuGroup.GET("/:id", controller.Get)
		appMenuGroup.PUT("/:id", controller.Update)
		appMenuGroup.DELETE("/:id", controller.Delete)
	}
}

func InitAppMenuRouter(appMenuResource *resource.AppMenuResource, s *core.AppServer) {
	controller := NewAppMenuController(appMenuResource)

	// 订单相关路由组
	appMenuGroup := s.Engine.Group("/appMenu")
	{
		appMenuGroup.POST("/create", controller.Create)
		appMenuGroup.GET("/:id", controller.Get)
		appMenuGroup.PUT("/:id", controller.Update)
		appMenuGroup.DELETE("/:id", controller.Delete)
	}
}

var Module = fx.Options(
	fx.Provide(
		resource.NewAppResource,
		resource.NewAppMenuResource,
	),
	fx.Invoke(
		InitAppRouter,
		InitAppMenuRouter,
	),
)
